<?php
@session_start();
$PurviewLevel=2;
$CheckChannelID=0;  
$PurviewLevel_Others="tongjing_diqu";

require("../../inc/common.inc.php");
require_once("../Admin_ChkPurview.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<TITLE>铭讯EOS网站后台管理</TITLE>
<Meta name="Keywords" Content="济南网站建设 济南网站制作 山东网站建设 济南铭讯软件有限公司">
<Meta name="Description" Content="济南网站制作：铭讯软件专业服务优秀企业，致力于网站建、设网站推广、网络营销一体的全访位网络服务商">
<link rel="stylesheet" href="../images/style.css" type="text/css">
</head>
<body> 
<?php
require("../mx_head.php");
?>
<div class="right">
<div class="gk">
	<div class="ti2 fl">地区分布</div>
	<ul class="fr">
		<li><span class="c1">120</span><span>用户总数</span></li>
		<li class="line"></li>
		<li><span class="c2">80</span><span>关注人数</span></li>
		<li class="line"></li>
		<li><span class="c3">40</span><span>取消关注</span></li>
	</ul>
	</div>
	<div class="clear"></div>
	<div class="height15"></div>
		<div class="xm2">
			<h1 class="fl">地区柱状图</h1>
			<div class="clear"></div>
		</div>
		<div class="xm2_b">
		<div class="height15"></div>
		<?php
		$startdate=formatdate($startdate);
		$enddate=formatdate($enddate);
//		if ($startdate=="" or $enddate==""){
//			$enddate=date("Y-m-d");
//			$startdate=date("Y-m-d",strtotime("$enddate - 30 day"));
//		}
		if ($actions==""){$actions="zhuce";}
		?>
		    <table width="98%" border="0" cellpadding="0" cellspacing="0" align="center">
              <tr>
                <td width="190" align="center">
<script>
	var jQuery_1 = $.noConflict(true);
    var minValidDate = 1372608000;
</script>	
<link rel="stylesheet" type="text/css" href="../js/date.css" charset="utf-8">
<script type="text/javascript" src="../js/gri.dateRange.js" charset="utf-8"></script>
<script type="text/javascript" src="../js/gri.js" charset="utf-8"></script>
<script type="text/javascript" src="../js/mta.js" charset="utf-8"></script>
<!--==时间范围start==-->
<form name="form1" id="form1" action="tj_diqu.php" method="get">
<input type="text" name="selectdate" id="selectdate" class="input1" style="width:180px;">
<input type="hidden" name="startdate" value="<?php echo $startdate;?>">
<input type="hidden" name="enddate" value="<?php echo $enddate;?>">
<input type="hidden" name="actions" value="<?php echo $actions;?>" />
</form>
<!--==时间范围end==-->
 
<script type="text/javascript"> 
    //应用的初始化参数
    var initParams = {
	"start_date": "<?php echo $startdate;?>",
	"end_date": "<?php echo $enddate;?>",	
	"need_compare": 1,
	};
 
    jQuery_1(document).ready(function(){
 
        var dateObj = {
            inputId:'selectdate',
            target:'datePicker',
            startDate: initParams.start_date || '',
            endDate: initParams.end_date || '',
            startCompareDate: initParams.start_compare_date || '',
            endCompareDate: initParams.end_compare_date || '',
            needCompare: initParams.need_compare || '1',
            defaultText : ''|| ' 至 ',
            singleCompare : '',
            isTodayValid: 0,
            minValidDate: minValidDate
        };
 
        //MTA.Page.Condition.source = new MTA.Selector('#div_source', 'source', initParams.source, 'buildData');
 
        MTA.Report.initialize(dateObj, 'buildData');
 
        //页面tips
    });
	function selectdate_submit(){
		var selectdatestr=document.form1.selectdate.value;
		if (selectdatestr!=""){
			selectdatearr=selectdatestr.split(' 至 ');
			if (selectdatearr.length==2){
				document.form1.startdate.value=selectdatearr[0];
				document.form1.enddate.value=selectdatearr[1];
				document.form1.submit();
			}
		}
	}
</script>
				</td>
                <td>
				<div class="an<?php if (trim($actions)=="lastupdate"){echo "1";}else{echo "2";}?>"><a href="tj_diqu.php?actions=lastupdate&startdate=<?php echo $startdate;?>&enddate=<?php echo $enddate;?>">最后更新地区</a></div>
				<div class="an<?php if (trim($actions)=="zhuce"){echo "1";}else{echo "2";}?>"><a href="tj_diqu.php?actions=zhuce&startdate=<?php echo $startdate;?>&enddate=<?php echo $enddate;?>">注册地区</a></div>
              </tr>
            </table>
	<div class="clear"></div>
		<div class="height15"></div>
			<div class="height15"></div>
				<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                    <td>
<script src="../js/jquery.min.js"></script>
<script src="../js/highcharts/tongji.js"></script>
<script src="../js/highcharts/highcharts.js"></script>
<script src="../js/handsontable/jquery.handsontable.full.js"></script>
<link rel="stylesheet" media="screen" href="../js/handsontable/jquery.handsontable.full.css">
<div id="data_div"></div>
<div id="charts" style="width: 99%; height:800px; margin: 0; padding: 0;"></div>
<script type="text/javascript"> 

<!--
var data = [
	["", "关注人数","取消关注"],
<?php
$str="";
$str2="";
$str3="";
if ($startdate!=""){
	$str.=" and guandate>='$startdate' ";
	$str2.=" and cguandate>='$startdate' ";
	$str3.=" and regdate>='$startdate' ";
}
if ($enddate!=""){
	$str.=" and guandate<='$enddate' ";
	$str2.=" and cguandate<='$enddate' ";
	$str3.=" and regdate<='$enddate' ";
}

$list="";
if ($actions=="zhuce"){
	$rs=$db->excu("select * from mx_view_diqu_zhuce");
}
else{
	$rs=$db->excu("select * from mx_view_diqu_last");
}
if ($db->num_rows($rs)>0){
	while ($rsdb=$db->fetch_array($rs)){
		if (trim($rsdb["sheng"])==""){$rsdb["sheng"]="其他";}
		if ($actions=="zhuce"){
			$vpp_guanzhu=$db->listcount("mx_user"," and wx_sheng='$rsdb[sheng]' and isguanzhu='1' $str");
			$app_guanzhu=$db->listcount("mx_app_user"," and province='$rsdb[sheng]' $str3");
			$cenal=$db->listcount("mx_user"," and wx_sheng='$rsdb[sheng]' and isguanzhu='0' $str2");
		}
		else{
			$vpp_guanzhu=$db->listcount("mx_user"," and province='$rsdb[sheng]' and isguanzhu='1' $str");
			$app_guanzhu=$db->listcount("mx_app_user"," and province='$rsdb[sheng]' $str3");
			$cenal=$db->listcount("mx_user"," and province='$rsdb[sheng]' and isguanzhu='0' $str2");
		}
		echo '["'.$rsdb["sheng"].'","'.($vpp_guanzhu+$app_guanzhu).'","'.$cenal.'"],';
		$list[]=array($rsdb["sheng"],($vpp_guanzhu+$app_guanzhu),$cenal);
	}
}
		if ($actions=="zhuce"){
			$vpp_guanzhu=$db->listcount("mx_user"," and (wx_sheng='' or wx_sheng is null) and isguanzhu='1' $str");
			$app_guanzhu=$db->listcount("mx_app_user"," and (province='' or province is null) $str3");
			$cenal=$db->listcount("mx_user"," and (wx_sheng='' or wx_sheng is null) and isguanzhu='0' $str2");
		}
		else{
			$vpp_guanzhu=$db->listcount("mx_user"," and (province='' or province is null) and isguanzhu='1' $str");
			$app_guanzhu=$db->listcount("mx_app_user"," and  (province='' or province is null) $str3");
			$cenal=$db->listcount("mx_user"," and (province='' or province is null) and isguanzhu='0' $str2");
		}
		if ($vpp_guanzhu>0 or $app_guanzhu>0 or $cenal>0){
		$rsdb["sheng"]="其他";
		echo '["'.$rsdb["sheng"].'","'.($vpp_guanzhu+$app_guanzhu).'","'.$cenal.'"],';
		$list[]=array($rsdb["sheng"],($vpp_guanzhu+$app_guanzhu),$cenal);
		}

?>
];

$(function(){
	$(document).ready(function() {
		var table = $('#data_div').handsontable({
			minRows: 1,
			minCols: 33,
			minSpareRows: 1,
			minSpareCols: 1,
			rowHeaders: true,
			colHeaders: true,
			data: data
		}).data('handsontable');
			var datagrid = table.getData();
			var type = "bar";
			var title = "";
			var ytitle = "人数";
			show_chart(type, title, ytitle,datagrid);
			return false;
	});
});
 
//-->
</script>
					</td>
                  </tr>
                </table>
				<div class="height15"></div>
	  </div>
		<div class="clear"></div>
		<div class="height15"></div>
        <div class="xm2">
          <h1 class="fl">详细数据</h1>
          <div class="clear"></div>
        </div>
		<div class="xm2_b">
		  <div class="height15"></div>
	
	<script type="text/javascript" src="../js/jquery.tablesorter.js"></script>
	<script type="text/javascript" src="../js/jquery.tablesorter.pager.js"></script>
<script type="text/javascript" id="js">$(document).ready(function() {
	$("table").tablesorter();
}); </script>
          <table width="98%" border="0" align="center" cellpadding="9" cellspacing="1" bgcolor="#CCCCCC" class="table_southidc" id="table">
		  <thead>
            <tr align="center">
              <th width="25%"><span>省份</span></th>
              <th width="25%"><span>关注人数</span></th>
              <th width="25%"><span>取消关注人数</span></th>
            </tr>
			</thead>
			<tbody>
			<?php
			if (is_array($list)){
				foreach ($list as $key =>$value){
			?>
            <tr align="center" class="list">
              <td><?php echo $value[0];?></td>
              <td><?php echo $value[1];?></td>
              <td><?php echo $value[2];?></td>
            </tr>
			<?php
				}
			}
			else{
			?>
			<tr class="list"><td align="center" colspan="3">暂无信息</td></tr>
			<?php
			}
			?>
			</tbody>
          </table>
		  
		  <div class="height15"></div>
	  </div>
		<div class="clear"></div>
  </div>
	
</div>
</div>
<?php require("../mx_foot.php");?>
</body>
</html>
